<?php
require $_SERVER['DOCUMENT_ROOT'].'/../_core/common.php';

$msg = array();

//权限验证
if( Role::init() == false ){
	$msg['error'] = false;
	$msg['string'] = '权限不足！';
	$myjson = json_encode($msg); 
	echo $myjson; 
	exit;
}

$db = new DB();

$id = isset($_POST['id']) ? h($_POST['id']) : '';

$user_sql = 'select id,username from users where id='.$id.' and groupid<>1 limit 1';
$user_rs = $db->query($user_sql)->getOne();

if( $user_rs['id'] < 1 ){//id不存在
	$msg['error'] = false;
	$msg['string'] = '参数有误！';
}else{
	//更新is_del字段
	$data=array('is_del'=>2,'updated'=>time());
	$db->table('users')->where('id='.$id)->update($data)->run();
	
	$msg['error'] = true;
	$msg['string'] = '成功删除成员 '.$user_rs['username'].' !';
}
$myjson = json_encode($msg); 
echo $myjson; 
exit;